<?php
class Tourism_key_word_model extends CI_Model
{
    private $table = 'tourism_key_word';
    
    public function findById($id)
    {
        $this->db->where('id',$id);
        return $this->db->get($this->table);
    }
    
    public function total($param = array())
    {
        if (!empty($param['keyword'])) {
            $this->db->like('keyword', $param['keyword']);
        }
        return $this->db->count_all_results($this->table);
    }

    public function page_list($page_num, $num, $param = array())
    {
        if (!empty($param['keyword'])) {
            $this->db->like('keyword', $param['keyword']);
        }
        $this->db->order_by('degree DESC');
        $this->db->limit($page_num, $num);
        return $this->db->get($this->table);
    }
    
     /**
     * 删除ID值
     * @param unknown $id
     */
    public function deleteById($id)
    {
        if (is_array($id)) {
            $this->db->where_in('id', $id);
        } else {
            $this->db->where('id', $id);
        }
        return $this->db->delete($this->table);
    }
}